package greedy;

import backTrack.Class51_1;

public class Class45 {

    public int jump(int[] nums) {
        if (nums.length==1){
            return 0;
        }
        int count=0;
        int cover=0;
        for (int i = 0; i <=cover; i++) {
            count++;
            cover=Math.max(i+nums[i],cover);
            if (cover>= nums.length-1){
                return  count;
            }
        }
        return count;
    }

    public static void main(String[] args) {
        Class45 class45 = new Class45();
        int[] arr={1,2,1,1,1};
        System.out.println(class45.jump(arr));
    }


}
